package org.iteye.bbjava.action;

import org.iteye.bbjava.model.User;
import org.iteye.bbjava.service.RegisterService;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String userName;
	String password;
	public User user;
	
	private RegisterService registerService;
	
	public LoginAction() {
		System.out.println("LoginAction init!");
	}

	public String execute() {
//		String index = (String)ServletActionContext.getRequest().getParameter("index");
//		System.out.println(index);
		/*String abc = (String)ServletActionContext.getRequest().getParameter("");
		System.out.println(abc);*/
		/*try {
			Document xml = AjaxXmlUtil.createDocumentFromRequest(ServletActionContext.getRequest());
			System.out.println(xml.asXML());
			AjaxXmlUtil.responseXML(ServletActionContext.getResponse(), xml.asXML());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
//		if(index.equals("1"))
			;
		if (user.getName().equals("zhang") && user.getPassword().equals("zhang1988"))
			return "success";
		return "toIndex";
	}
	
	public String regiest(){
		int i = registerService.regest(user);
		if( i == 1 ){
			return SUCCESS;
		}else{
			return ERROR;
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public RegisterService getRegisterService() {
		return registerService;
	}

	public void setRegisterService(RegisterService registerService) {
		this.registerService = registerService;
	}


}
